package archer.framework.security.token.impl;

import archer.framework.security.ArcherSecurityModule;
import archer.framework.security.token.Token;
import archer.framework.utils.IdGenerator;

import java.util.Map;

/**
 * @author christ
 * @date 2016/5/31
 */
public class DefaultTokenCreator {


    public static Token create(Map<Object, Object> attrs) {

        return create(ArcherSecurityModule.defaultTokenTimeout, attrs);
    }

    public static Token create(long timeout, Map<Object, Object> attrs) {

        DefaultToken token = new DefaultToken();
        token.setId(IdGenerator.generate32());
        token.setAttributes(attrs);
        token.setTimeout(timeout);
        return token;
    }
}
